package com.zyf.recruit.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zyf.recruit.dao.RecruitDao;
import com.zyf.recruit.pojo.Recruit;
import com.zyf.recruit.service.RecruitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
@CacheConfig(cacheNames = "recruit_")
public class RecruitServiceImpl extends ServiceImpl<RecruitDao, Recruit> implements RecruitService {
    @Autowired
    RecruitDao recruitDao;
//    需求分析：查询状态为2并以创建日期降序排序，查询前n条记录
    @Cacheable(key = "#n")
    @Override
    public List findTopNByStateOrderByCreateTimeDesc(int n,String state) {
        HashMap<String,Object> hashMap=new HashMap<>();
        hashMap.put("state",state);
        hashMap.put("n",n);
        return recruitDao.findTopNByStateOrderByCreateTimeDesc(hashMap);
    }
}
